﻿<!DOCTYPE html>
<html>
<!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:03 GMT -->

<head>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" href="/admin/plugins/bootstrap-table/bootstrap.min.css" />
    <link rel="stylesheet" href="/admin/plugins/bootstrap-table/bootstrap-table.min.css" />
    <link href="/admin/static/css/common.css" rel="stylesheet" />
    <script src="/admin/static/js/jquery.min.js"></script>
    <script src="/admin/static/js/bootstrap.min.js"></script>
    <script src="/admin/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/admin/plugins/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
    <script src="/admin/plugins/layer/layer.js"></script>
    <style>
        .fixed-table-pagination {
            display: none !important;
        }
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <h4>
                    <small></small>
                </h4>
                <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                    <button id="btn_add" type="button" class="btn btn-primary btn-default">
                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>新增
                    </button>
                    <button id="btn_del" type="button" class="btn btn-danger btn-default">
                        <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>删除
                    </button>
                    
                    <button id="btn_auth" type="button" style="border-width:0px;margin:0;padding:0;" >
                        <img alt="" src="/images/icon_button3_2.png" style="border-width:0px;margin:0;padding:0;" />
                    </button>
                    <a style="border-width:0px;margin:0;padding:0 10px;font-size:18px;float:left;">http://openwx.jmbbstp.cn/getcode.aspx</a>
                </div>
                <table id="exampleTableEvents" data-sort-class="aaa" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>

    <script>
        $(function () {
            $("#btn_add").click(function () {
                window.lastIndex = layer.open({
                    type: 2,
                    title: '新增授权信息',
                    shadeClose: false,
                    scrollbar: false,
                    shade: [0.8, '#393D49'],
                    area: ['600px', '450px'],
                    content: 'add.html?formid=&rnd=' + Math.random()
                });
            });
            $("#btn_auth").click(function () {
                window.lastIndex = layer.open({
                    type: 2,
                    title: '公众号授权',
                    shadeClose: false,
                    scrollbar: false,
                    shade: [0.8, '#393D49'],
                    area: ['90%', '90%'],
                    content:"/getauthcode"
                });
            });
            $("#btn_reset").click(function () {
                $("#keywords").val('');
                table.bootstrapTable('refresh');
            });
            $("#btn_del").click(function () {
                layer.confirm('是否确认删除该数据?', {
                    btn: ['确认删除', '取消'] //按钮
                }, function () {
                    if ($("input[name=btSelectItem]:checked").size() == 0) {
                        layer.alert("请选择要删除的数据", { icon: 2, closeBtn: 0 });
                        return;
                    }
                    if (window.isgetting == true) { return; }
                    window.isgetting = true;
                    var getSelectRows = $("#exampleTableEvents").bootstrapTable('getSelections');
                    var ids = [];
                    $.each(getSelectRows, function (i, row) { ids.push(row.id); });
                    $.ajax({
                        type: "POST",
                        url: "/Domains/del?rnd=" + Math.random(),
                        data: { Action:"del", del_id: ids.join('|') },
                        timeout: 5000,
                        dataType: "json",
                        success: function (data) {
                            if (data.sucess == true) {
                                window.lastIndex = layer.alert('删除数据成功', { icon: 1, closeBtn: 0 }, function () { closeLayer(true); });
                            }
                            else {
                                layer.alert('删除数据失败,' + data.info, { icon: 2, closeBtn: 0 });
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert('删除数据错误,' + errorThrown, { icon: 2, closeBtn: 0 });
                        },
                        complete: function () {
                            delete window.isgetting;
                        }
                    });
                });
            });
        });
        function edit(id) {
            window.lastIndex = layer.open({
                type: 2,
                title: '编辑授权信息',
                shadeClose: false,
                scrollbar: false,
                shade: [0.8, '#393D49'],
                area: ['600px', '450px'],
                content: 'add.html?formid=&rowid=' + id + '&rnd=' + Math.random()
            });
        };
        function closeLayer(refush) {
            layer.close(window.lastIndex);
            if (refush) {
                table.bootstrapTable('refresh');
            }
        }
        var table = $('#exampleTableEvents').bootstrapTable({
            url: "/Domains/query?Action=query",
            method: 'POST',
            contentType: "application/x-www-form-urlencoded",
            pagination: true,
            pageNumber: 1,
            pageSize: 30,
            pageList: [10, 20, 30, 50, 100],
            sortable: true,
            sortOrder: "desc",
            queryParams: function (params) {
                return {
                    pagesize: params.limit, //每一页的数据行数，默认是上面设置的10(pageSize)
                    pageindex: params.offset / params.limit + 1, //当前页面,默认是上面设置的1(pageNumber)
                    sort: params.sort,      //排序列名
                    sortOrder: params.order, //排位命令（desc，asc）
                    keywords: $("#keywords").val() //这里是其他的参数，根据自己的需求定义，可以是多个
                }
            },
            responseHandler: function (result) {
                var data = { "total": 1, "rows": [] };
                data.rows = result.data;
                data.total = result.data.length;
                return data;
            },
            columns: [{
                checkbox: true,
            }, {
                    field: 'id',
                    title: 'ID',
                    width: 60
                }, {
                    field: 'name',
                    title: '名称',
                    width: 180
                }, {
                    field: 'appid',
                    title: '小程序AppId',
                    width: 180
                }, {
                    field: 'host',
                    title: '域名',
                    width: 200
                },
                {
                    field: 'scope',
                    title: '授权方式',
                    formatter: function (value, row, index) {
                        return value==1?"获取信息":"静默授权";
                    },
                    width: 110
                },
                {
                    field: 'state',
                    title: '标识',
                    width: 130
                }, {
                    field: 'adddate',
                    title: '添加时间',
                    width: 180
                },
                {
                    field: '',
                    title: '操作',
                    formatter: function (value, row, index) {
                        var html = '<button type="button" onclick="edit(' + row['id'] + ')" style="padding:2px 5px;" class="btn btn-info btn-primary"><i class="glyphicon glyphicon-edit" aria-hidden="true"></i>编辑</button>';
                        return html;
                }
            }],
            search: false,
            striped: true,
            sidePagination: 'server',
            showRefresh: true,
            cache: false,
            showToggle: true,
            showColumns: true,
            minimumCountColumns: 2,
            iconSize: "outline",
            paginationFirstText: '首页',
            paginationLastText: '尾页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            toolbar: "#exampleTableEventsToolbar"
        });
        $("#btnQuery").click(function () {
            table.bootstrapTable('refresh', $.extend(table.bootstrapTable("getOptions"), { pageNumber: 1 }));
        });
    </script>
</body>

</html>